<?php

namespace app\company\validate;


class StoreValidate extends BaseValidate
{
    public function __construct()
    {
        $rule = [
            'name'         => 'require|max:30',
            "real_name"    => 'require|max:10',
            "mobile"       => 'require|mobile|unique:store_user',
            "address"      => 'require|max:100',
            "long"         => 'require|float',
            "lat"          => 'require|float',
            "bank_type"    => 'requireIf:is_on_credit,1|length:1,15',
            "bank_branch"  => 'requireIf:is_on_credit,1|max:100',
            "bank_no"      => 'requireIf:is_on_credit,1|max:50',
            "user_name"    => 'requireIf:is_on_credit,1|max:10',
            "is_on_credit" => 'require|in:1,2',
            "credit_days"  => 'requireIf:is_on_credit,1',
        ];

        $message = [
            'name.require'           => '门店名称必须',
            'name.max'               => '门店名称最多不能超过30个字符',
            'real_name.require'      => '真实姓名必须',
            'real_name.max'          => '真实姓名最多不能超过10个字符',
            'mobile.require'         => '手机号必须',
            'mobile.mobile'          => '手机号格式错误',
            'mobile.unique'          => '手机号已存在',
            'address.require'        => '门店地址必须',
            'address.max'            => '门店地址最多不能超过100个字符',
            'long.require'           => '经度必须',
            'long.float'             => '经度格式错误',
            'lat.require'            => '纬度必须',
            'lat.float'              => '纬度格式错误',
            'bank_type.requireIf'    => '银行类型必须',
            'bank_type.length'       => '银行类型格式错误',
            'bank_branch.requireIf'  => '开户行必须',
            'bank_branch.max'        => '开户行最多不能超过100个字符',
            'bank_no.requireIf'      => '银行卡号必须',
            'bank_no.max'            => '银行卡号最多不能超过50个字符',
            'user_name.requireIf'    => '户名必须',
            'user_name.max'          => '户名最多不能超过10个字符',
            'is_on_credit.requireIf' => '是否支持账期支付必须',
            'is_on_credit.in'        => '是否支持账期支付值错误',
            'credit_days.requireIf'  => '账期天数必须',
        ];

        $scene = [
            'add'    => ['name', 'real_name', 'mobile', 'address'],
            'import' => ['name', 'real_name', 'address', 'long', 'lat'],//导入
        ];
        parent::__construct($rule, $message, $scene);
    }
}